# -*-coding: utf-8 -*-
import urllib
import time

domains = []
with open('ns6.csv', 'rb') as file_obj:
    for line in file_obj:
        domains.append(line.replace('\r\n', ''))

with open('yaode.csv', 'wb') as file_obj:
    for domain in domains:
        print domain
        req = urllib.urlopen('http://www.sfn.cn/whois/whoisResult?flag=flag&whoisName=' + domain)
        response_txt = req.read().lower()
        if response_txt.find('ns6.sanfront.com.cn') >= 0 or response_txt.find('ns4.sanfront.com.cn') >= 0:
            file_obj.write(domain)
            file_obj.write('\n')
            file_obj.flush()
        time.sleep(0.1)
